#include<iostream>
#include<opencv2/imgcodecs.hpp>
#include<opencv2/highgui.hpp>
#include<opencv2/imgproc.hpp>
#include<opencv2/objdetect.hpp>
#include<opencv2/opencv.hpp>
#include<opencv2/ximgproc.hpp>
#include<string>
#include<vector>
#include<fstream>
#include <fcntl.h>
#include <termios.h>
#include"func.h"

using namespace std;
using namespace cv;

void targetBinarization(const Mat& img, Mat& targetBinImg) 
{
    
    Mat hsvImg;
    cvtColor(img, hsvImg, COLOR_BGR2HSV);

    Scalar upper(39,255,255);
    Scalar lower(0,74,193);
    // Scalar upper(Hmax,Smax,Vmax);//多通道数据结构
    // Scalar lower(Hmin,Smin,Vmin);

    inRange(hsvImg, lower, upper, targetBinImg);

    Mat st1 = getStructuringElement(0, Size(9, 9));
    dilate(targetBinImg, targetBinImg, st1);
    erode(targetBinImg, targetBinImg, st1);

    imshow("targetBinImg", targetBinImg);

}

void towardbinarization(Mat img,Mat& towardBinImg)//激光枪口指向二值化函数
{

    Mat hsvImg;
    cvtColor(img, hsvImg, COLOR_BGR2HSV);

    Scalar upper(180,255,255);//多通道数据结构
    Scalar lower(72,24,147);
    // Scalar upper(Hmax,Smax,Vmax);//多通道数据结构
    // Scalar lower(Hmin,Smin,Vmin);


    inRange(hsvImg,lower,upper,towardBinImg);

    Mat st1 = getStructuringElement(0,Size(9,9));//结构元素生成
    dilate(towardBinImg,towardBinImg,st1);//膨胀
    erode(towardBinImg,towardBinImg,st1);//腐蚀

    imshow("towardBinImg",towardBinImg);
    // cout<<Hmax<<","<<Smax<<","<<Vmax<<","<<Hmin<<","<<Smin<<","<<Vmin<<"tow"<<endl;

}
